﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using WebCurriculumn.Modal;
using System.Collections.Generic;
using WebCurriculumn.Helps;
using WebCurriculumn.DBAcess;

namespace WebCurriculumn.BLL
{
    public class CurriCulumnModual
    {
        public List<CurriCulumnEntity> GetCurriCulumnInfoList(int iSubjectGradeId)
        {

            List<CurriCulumnEntity> listCulumn = new List<CurriCulumnEntity>();
            using (DBContext db = new DBContext())
            {
                SqlResult result = db.CallProcedure("usp_webCurriCulumnInfo_getBySubjectGradeProfileID", iSubjectGradeId);
                if (result.DataSet.Tables.Count > 0 && result.DataSet.Tables[0].Rows.Count > 0)
                {
                    DataTable dt = result.DataSet.Tables[0];
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        CurriCulumnEntity entiy = new CurriCulumnEntity
                        {
                            Index = i + 1,
                            CurriCulumnDate = DateTime.Parse(dt.Rows[i]["dtplan"].ToString()).ToString("yyyy/MM/dd"),
                            CurriCulumnType = dt.Rows[i]["iClassTypePlanId"].ToString() == "1" ? "講義" : dt.Rows[i]["iClassTypePlanId"].ToString() == "2" ? "実習" : "",
                            CurriCulumnHours = MyUtils.ParseToInt(dt.Rows[i]["fUnitTimePlan"].ToString(), 0),
                            Content = dt.Rows[i]["vClassContents"].ToString(),
                            StartTime = dt.Rows[i]["dtStartTimePlan"].ToString(),
                            EndTime = dt.Rows[i]["dtEndTimePlan"].ToString(),
                            RecorderPeople = "",
                            Status = dt.Rows[i]["istatusID"].ToString(),
                            ClassID = int.Parse(dt.Rows[i]["iClassId"].ToString()),
                            SBOFile = dt.Rows[i]["vGISSBOPath"].ToString(),
                            CurriCulumnStatusID = dt.Rows[i]["iCurriCulumnStatusID"].ToString(),
                            SBO = dt.Rows[i]["SBO"].ToString(),
                            GIO = dt.Rows[i]["GIO"].ToString(),
                        };
                        listCulumn.Add(entiy);
                    }
                }

            }
            return listCulumn;
        }
    }
}
